//
//  FMTitleTableViewCell.m
//  XWZ_News_Work
//
//  Created by dllo on 16/1/11.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "FMTitleTableViewCell.h"


@interface FMTitleTableViewCell ()

@property (nonatomic, strong) UIButton *buttonDown;
@property (nonatomic, strong) UIButton *buttonCollect;

@end

@implementation FMTitleTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubview];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    [self.buttonDown mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.contentView.mas_centerY);
        make.left.equalTo(self.contentView.mas_left).with.offset(0);
        make.right.equalTo(self.buttonCollect.mas_left).with.offset(-1);
        make.bottom.equalTo(self.contentView).with.offset(0);
        make.top.equalTo(self.contentView).with.offset(0);
        make.width.equalTo(self.buttonCollect);
        
    }];
    
    [self.buttonCollect mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.contentView.mas_centerY);
        make.right.equalTo(self.contentView.mas_right).with.offset(0);
        make.left.equalTo(self.buttonDown.mas_right).with.offset(1);
        make.top.equalTo(self.contentView).with.offset(0);
        make.bottom.equalTo(self.contentView).with.offset(0);
        make.width.equalTo(self.buttonDown);
        
    }];
    
    
}


- (void)createSubview
{
    self.backgroundColor = [UIColor whiteColor];
    
    self.buttonDown = [UIButton buttonWithType:UIButtonTypeCustom];
    //    self.buttonDown.backgroundColor = [UIColor redColor];
    [self.buttonDown setTitle:@"我的下载" forState:UIControlStateNormal];
    
    [self.buttonDown addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.buttonDown setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [self.contentView addSubview:self.buttonDown];
    
    
    self.buttonCollect = [UIButton buttonWithType:UIButtonTypeCustom];
    //    self.buttonCollect.backgroundColor = [UIColor redColor];
    [self.buttonCollect addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.buttonCollect setTitle:@"我的收藏" forState:UIControlStateNormal];
    [self.buttonCollect setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [self.contentView addSubview:self.buttonCollect];
    
    
}

- (void)buttonAction:(UIButton *)sender
{
    if (sender == self.buttonDown) {
        NSLog(@"1111");
    } else {
    
        NSLog(@"2222");
    
    }
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
